<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="xml" />
<xsl:key name="classId" match="//Foundation.Core.Class[@xmi.id] | //Foundation.Core.Interface[@xmi.id] | //Foundation.Core.AssociationClass[@xmi.id]" use="@xmi.id"/>

<xsl:key name="attributeId" match="//Foundation.Core.Interface[@xmi.id] | //Model_Management.Model[@xmi.id]/Foundation.Core.Namespace.ownedElement/Foundation.Data_Types.Enumeration[@xmi.id] | //Foundation.Core.DataType[@xmi.id] | //Foundation.Core.Class[@xmi.id]" use="@xmi.id"/>

<xsl:key name="stereotypeId" match="//Model_Management.Model[@xmi.id]/Foundation.Core.Namespace.ownedElement/Foundation.Extension_Mechanisms.Stereotype[@xmi.id]" use="@xmi.id"/>



<xsl:variable name="GraphicPositionScale" select="1 div 3"/>
<xsl:variable name="GraphicSizeScale" select="1 div 3"/>

<xsl:template match="/">
<UMLEditor>
	<Model>
		<!-- Package -->
		<xsl:apply-templates select="//Model_Management.Model[@xmi.id]"/>
		
		<!-- Héritage -->
		<xsl:apply-templates select="//Foundation.Core.Generalization[@xmi.id]"/>
		
		<!-- Implémentation -->
		<xsl:apply-templates select="//Foundation.Core.Classifier.realization"/>
		
		<!-- Association -->
		<xsl:apply-templates select="//Foundation.Core.Association[@xmi.id]" mode="Association"/>
		<xsl:apply-templates select="//Foundation.Core.AssociationClass[@xmi.id]" mode="Association"/>

	</Model>
		
</UMLEditor>
</xsl:template>

<!-- Model (Package) -->
<xsl:template match="Model_Management.Model">
	<xsl:element name="Package">
		<xsl:attribute name="name"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="documentation"/>
		
		<xsl:for-each select=".//Foundation.Core.Class[@xmi.id]">
			<xsl:variable name="idstereotype" select="Foundation.Core.ModelElement.stereotype/Foundation.Extension_Mechanisms.Stereotype/@xmi.idref"/>
			<xsl:variable name="stereotype" select="key('stereotypeId', $idstereotype)/Foundation.Core.ModelElement.name"/>
			
			<xsl:choose>
				<xsl:when test="$stereotype='Enumeration'">
					<!-- énumération -->
					<xsl:apply-templates select="." mode="Enumeration"/>
				</xsl:when>
				
				<xsl:otherwise>
					<!-- classes -->
					<xsl:apply-templates select="." mode="Class"/>
				</xsl:otherwise>
			</xsl:choose>
			
		</xsl:for-each>
		
		<!-- classe d'association -->
		<xsl:apply-templates select="//Foundation.Core.AssociationClass[@xmi.id]" mode="AssociationClass"/>
		
		<!-- interfaces -->
		<xsl:apply-templates select=".//Foundation.Core.Interface[@xmi.id]" mode="Interface"/>
		
	</xsl:element>
</xsl:template>

<!-- Classes -->
<xsl:template match="Foundation.Core.Class" mode="Class">
	<xsl:element name="Class">
		<xsl:attribute name="name"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="documentation">
			<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/>
		</xsl:attribute>
		<xsl:attribute name="visibility">v_<xsl:value-of select="Foundation.Core.ModelElement.visibility/@xmi.value"/></xsl:attribute>
		<xsl:attribute name="abstract"><xsl:value-of select="Foundation.Core.GeneralizableElement.isAbstract/@xmi.value"/></xsl:attribute>
		<xsl:attribute name="final">false</xsl:attribute>
		
		<xsl:variable name="idstereotype" select="Foundation.Core.ModelElement.stereotype/Foundation.Extension_Mechanisms.Stereotype/@xmi.idref"/>
		<xsl:attribute name="stereotype"><xsl:value-of select="key('stereotypeId', $idstereotype)/Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="associationClass">false</xsl:attribute>
		
		<!-- Attributs -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Attribute[@xmi.id]" mode="Property"/>
		
		<!-- Operations -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Operation[@xmi.id]" mode="Operation"/>
		
	</xsl:element>
</xsl:template>

<!-- Classes d'association-->
<xsl:template match="Foundation.Core.AssociationClass" mode="AssociationClass">
	<xsl:element name="Class">
		<xsl:attribute name="name"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="documentation">
			<xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/>
		</xsl:attribute>
		<xsl:attribute name="visibility">v_<xsl:value-of select="Foundation.Core.ModelElement.visibility/@xmi.value"/></xsl:attribute>
		<xsl:attribute name="abstract"><xsl:value-of select="Foundation.Core.GeneralizableElement.isAbstract/@xmi.value"/></xsl:attribute>
		<xsl:attribute name="final">false</xsl:attribute>
		
		<xsl:variable name="idstereotype" select="Foundation.Core.ModelElement.stereotype/Foundation.Extension_Mechanisms.Stereotype/@xmi.idref"/>
		<xsl:attribute name="stereotype"><xsl:value-of select="key('stereotypeId', $idstereotype)/Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="associationClass">true</xsl:attribute>
		
		<!-- Attributs -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Attribute[@xmi.id]" mode="Property"/>
		
		<!-- Operations -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Operation[@xmi.id]" mode="Operation"/>
		
	</xsl:element>
</xsl:template>

<!-- Attributs -->
<xsl:template match="Foundation.Core.Attribute" mode="Property">
	<xsl:element name="Property">
		<xsl:attribute name="name"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="documentation"><xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/></xsl:attribute>
		
	<!--	<xsl:choose>
			
			<xsl:when test="Foundation.Core.StructuralFeature.type/Foundation.Data_Types.Enumeration">
				<xsl:variable name="idvalue" select="Foundation.Core.StructuralFeature.type/Foundation.Data_Types.Enumeration/@xmi.idref"/>
				
				<xsl:choose>
					<xsl:when test="key('attributeId',$idvalue)/Foundation.Core.ModelElement.name = '&lt;undefined&gt;'">
						<xsl:attribute name="type">void</xsl:attribute>
					</xsl:when>
					<xsl:otherwise>
						<xsl:attribute name="type"><xsl:value-of select="key('attributeId',$idvalue)/Foundation.Core.ModelElement.name"/></xsl:attribute>
					</xsl:otherwise>
				</xsl:choose>
				
			</xsl:when>
			
			
			<xsl:when test="Foundation.Core.StructuralFeature.type/Foundation.Core.DataType">
				<xsl:variable name="idvalue" select="Foundation.Core.StructuralFeature.type/Foundation.Core.DataType/@xmi.idref"/>
				
				<xsl:choose>
					<xsl:when test="key('attributeId',$idvalue)/Foundation.Core.ModelElement.name = '&lt;undefined&gt;'">
						<xsl:attribute name="type">void</xsl:attribute>
					</xsl:when>
					<xsl:otherwise>
						<xsl:attribute name="type"><xsl:value-of select="key('attributeId',$idvalue)/Foundation.Core.ModelElement.name"/></xsl:attribute>
					</xsl:otherwise>
				</xsl:choose>

			</xsl:when>
		</xsl:choose>-->
		
		<xsl:variable name="idvalue" select="Foundation.Core.StructuralFeature.type/child::node()/@xmi.idref"/>
		
		<xsl:choose>
			<xsl:when test="key('attributeId',$idvalue)/Foundation.Core.ModelElement.name = '&lt;undefined&gt;'">
				<xsl:attribute name="type">void</xsl:attribute>
			</xsl:when>
			<xsl:otherwise>
				<xsl:attribute name="type"><xsl:value-of select="key('attributeId',$idvalue)/Foundation.Core.ModelElement.name"/></xsl:attribute>
			</xsl:otherwise>
		</xsl:choose>
		
		
		<xsl:attribute name="visibility">v_<xsl:value-of select="Foundation.Core.ModelElement.visibility/@xmi.value"/></xsl:attribute>
		<xsl:attribute name="static">???</xsl:attribute>
		<xsl:attribute name="defaultValue"><xsl:value-of select="Foundation.Core.Attribute.initialValue/Foundation.Data_Types.Expression/Foundation.Data_Types.Expression.body"/></xsl:attribute>

		<xsl:variable name="idType" select="Foundation.Core.StructuralFeature.type/child::node()/@xmi.idref"/>
		<xsl:variable name="idstereotype" select="key('attributeId', $idType)/Foundation.Core.ModelElement.stereotype/Foundation.Extension_Mechanisms.Stereotype/@xmi.idref"/>
		<xsl:variable name="stereotype" select="key('stereotypeId', $idstereotype)/Foundation.Core.ModelElement.name"/>

		<xsl:if test="$stereotype = 'Enumeration' ">
			<xsl:attribute name="isEnum">true</xsl:attribute>
		</xsl:if>
			
	</xsl:element>
</xsl:template>

<!-- Operations -->
<xsl:template match="Foundation.Core.Operation" mode="Operation">
	<xsl:element name="Operation">
		<xsl:attribute name="name"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="documentation"><xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/></xsl:attribute>
		
		<xsl:variable name="returnTypeIdValue" select=".//Foundation.Core.Parameter[@xmi.id]/Foundation.Core.Parameter.kind[@xmi.value='return']/../Foundation.Core.Parameter.type/Foundation.Core.DataType/@xmi.idref "/>

		<xsl:attribute name="type"><xsl:value-of select="key('attributeId', $returnTypeIdValue)/Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="visibility">v_<xsl:value-of select="Foundation.Core.ModelElement.visibility/@xmi.value"/></xsl:attribute>
		<xsl:attribute name="static">???</xsl:attribute>
		<xsl:attribute name="modifier">m_none</xsl:attribute>
		<xsl:attribute name="code"/>
		
		<xsl:for-each select="Foundation.Core.BehavioralFeature.parameter/Foundation.Core.Parameter/Foundation.Core.Parameter.kind[@xmi.value='inout']/..">
			<xsl:element name="Parameter">
				<xsl:attribute name="name"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
				
				<xsl:variable name="idvalue" select="Foundation.Core.Parameter.type/Foundation.Core.DataType/@xmi.idref"/>
								
				<xsl:attribute name="type"><xsl:value-of select="key('attributeId', $idvalue)/Foundation.Core.ModelElement.name"/></xsl:attribute>
				<xsl:attribute name="documentation"/>
			</xsl:element>
		</xsl:for-each>
		
		
	</xsl:element>
</xsl:template>

<!-- Interface -->
<xsl:template match="Foundation.Core.Interface" mode="Interface">
	<xsl:element name="Interface">
		<xsl:attribute name="name"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="documentation"><xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/></xsl:attribute>
		<xsl:attribute name="visibility">v_<xsl:value-of select="Foundation.Core.ModelElement.visibility/@xmi.value"/></xsl:attribute>
		<xsl:attribute name="final">???</xsl:attribute>
		
		<!-- Attributs -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Attribute[@xmi.id]" mode="Property"/>
		
		<!-- Operations -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Operation[@xmi.id]" mode="Operation"/>
		
	</xsl:element>
</xsl:template>


<!-- Enumeration -->
<xsl:template match="Foundation.Core.Class" mode="Enumeration">
	<xsl:element name="Enumeration">
		<xsl:attribute name="name"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="documentation"><xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/></xsl:attribute>
		<xsl:attribute name="visibility">v_<xsl:value-of select="Foundation.Core.ModelElement.visibility/@xmi.value"/></xsl:attribute>
		<xsl:attribute name="final">???</xsl:attribute>
		
		<!-- Literal -->
		<xsl:apply-templates select="Foundation.Core.Classifier.feature/Foundation.Core.Attribute[@xmi.id]" mode="Literal"/>
		
	</xsl:element>
</xsl:template>

<!-- literal -->
<xsl:template match="Foundation.Core.Attribute" mode="Literal">
	<xsl:element name="Property">
		<xsl:attribute name="name"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="documentation"><xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/></xsl:attribute>
		<xsl:attribute name="type"/>
		<xsl:attribute name="visibility"/>
		<xsl:attribute name="static"/>
		<xsl:attribute name="defaultValue"/>

	</xsl:element>
</xsl:template>


<!-- l'héritage -->
<xsl:template match="Foundation.Core.Generalization">
	<xsl:element name="Generalization">
		<xsl:attribute name="name"><xsl:apply-templates select="." mode="GetGeneralizationName"/></xsl:attribute>
		<xsl:attribute name="documentation"><xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/></xsl:attribute>
		<xsl:variable name="idvalue1" select="Foundation.Core.Generalization.subtype/Foundation.Core.Class/@xmi.idref"/>
		<xsl:variable name="idvalue2" select="Foundation.Core.Generalization.supertype/Foundation.Core.Class/@xmi.idref"/>
		<xsl:attribute name="clientClassName"><xsl:value-of select="key('classId',$idvalue1)/Foundation.Core.ModelElement.name"/></xsl:attribute>
		<xsl:attribute name="supplierClassName"><xsl:value-of select="key('classId',$idvalue2)/Foundation.Core.ModelElement.name"/></xsl:attribute>
	</xsl:element>
</xsl:template>

<!-- retourne le nom de l'héritage -->
<xsl:template match="Foundation.Core.Generalization" mode="GetGeneralizationName">
	<xsl:choose>
		<xsl:when test="Foundation.Core.ModelElement.name != '' "><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:when>
		<xsl:otherwise><xsl:value-of select="@xmi.id"/></xsl:otherwise>
	</xsl:choose>
</xsl:template>

<!-- l'implémentation -->
<xsl:template match="Foundation.Core.Classifier.realization">
	<xsl:for-each select="Foundation.Core.Class">
		<xsl:element name="Implementation">
			<xsl:attribute name="name"><xsl:value-of select="../../../Foundation.Core.Interface/@xmi.id"/><xsl:value-of select="@xmi.idref"/></xsl:attribute>
			<xsl:attribute name="documentation"><xsl:apply-templates select="Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/></xsl:attribute>
			<xsl:variable name="idvalue" select="@xmi.idref"/>
			<xsl:attribute name="clientClassName"><xsl:value-of select="key('classId',$idvalue)/Foundation.Core.ModelElement.name"/></xsl:attribute>
			<xsl:attribute name="supplierClassName"><xsl:value-of select="../../Foundation.Core.ModelElement.name"/></xsl:attribute>
		</xsl:element>
	</xsl:for-each>
</xsl:template>

<!-- l'Association -->
<xsl:template match="Foundation.Core.Association" mode="Association">
	<xsl:element name="Association">
		<xsl:attribute name="name"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationName"/></xsl:attribute>
		<xsl:attribute name="documentation"><xsl:apply-templates select="../Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/></xsl:attribute>
		<xsl:attribute name="type"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationType"/></xsl:attribute>
		<xsl:attribute name="navigable"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationNavigability"/></xsl:attribute>

		<xsl:variable name="client"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClient"/></xsl:variable>
		<xsl:variable name="supplier"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationSupplier"/></xsl:variable>

		<xsl:attribute name="associationClassifier"/>
		
		<xsl:attribute name="clientClassName">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClassName"><xsl:with-param name="role" select="$client"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="clientRole">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationRoleName"><xsl:with-param name="role" select="$client"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="clientMultiplicity">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationMultiplicity"><xsl:with-param name="role" select="$client"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="clientQualifierName"/>
		<xsl:attribute name="clientQualifierType"/>
		<xsl:attribute name="supplierClassName">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClassName"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="supplierRole">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationRoleName"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="supplierMultiplicity">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationMultiplicity"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="supplierQualifierName"></xsl:attribute><!-- non défini -->
		<xsl:attribute name="supplierQualifierType"></xsl:attribute>
	</xsl:element>
</xsl:template>

<!-- l'Association avec classe d'association-->
<xsl:template match="Foundation.Core.AssociationClass" mode="Association">
	<xsl:element name="Association">
		<xsl:attribute name="name"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationName"/></xsl:attribute>
		<xsl:attribute name="documentation"><xsl:apply-templates select="../Foundation.Core.ModelElement.taggedValue" mode="GetDocumentation"/></xsl:attribute>
		<xsl:attribute name="type"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationType"/></xsl:attribute>
		<xsl:attribute name="navigable"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationNavigability"/></xsl:attribute>

		<xsl:variable name="client"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClient"/></xsl:variable>
		<xsl:variable name="supplier"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationSupplier"/></xsl:variable>

		<xsl:attribute name="associationClassifier"><xsl:value-of select="Foundation.Core.ModelElement.name"/></xsl:attribute>
		
		<xsl:attribute name="clientClassName">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClassName">
				<xsl:with-param name="role" select="$client"/>
			</xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="clientRole">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationRoleName"><xsl:with-param name="role" select="$client"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="clientMultiplicity">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationMultiplicity"><xsl:with-param name="role" select="$client"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="clientQualifierName"/>
		<xsl:attribute name="clientQualifierType"/>
		<xsl:attribute name="supplierClassName">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClassName"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="supplierRole">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationRoleName"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="supplierMultiplicity">
			<xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationMultiplicity"><xsl:with-param name="role" select="$supplier"/></xsl:apply-templates>
		</xsl:attribute>
		<xsl:attribute name="supplierQualifierName"></xsl:attribute><!-- non défini -->
		<xsl:attribute name="supplierQualifierType"></xsl:attribute>
	</xsl:element>
</xsl:template>


<!-- retourne le nom de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationName">
	<xsl:choose>
		<xsl:when test="../Foundation.Core.ModelElement.name != '' "><xsl:value-of select="../Foundation.Core.ModelElement.name"/></xsl:when>
		<xsl:otherwise><xsl:value-of select="../@xmi.id"/></xsl:otherwise>
	</xsl:choose>
</xsl:template>

<!-- retourne le type de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationType">
	<xsl:variable name="class1" select="Foundation.Core.AssociationEnd[1]/Foundation.Core.AssociationEnd.aggregation/@xmi.value"/>
	<xsl:variable name="class2" select="Foundation.Core.AssociationEnd[2]/Foundation.Core.AssociationEnd.aggregation/@xmi.value"/>

	<xsl:choose>
		<xsl:when test="$class1='none' and $class2='none'">association</xsl:when>
		<xsl:when test="$class1='shared' or $class2='shared'">aggregation</xsl:when>
		<xsl:when test="$class1='composite' or $class2='composite'">composition</xsl:when>
		
		<!-- Visio -->
		<xsl:when test="$class1='partag' or $class2='partag' ">aggregation</xsl:when> <!-- paratgé -->
	</xsl:choose>
</xsl:template>

<!-- retourne le client de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationClient">
	<xsl:variable name="class1" select="Foundation.Core.AssociationEnd[1]/Foundation.Core.AssociationEnd.aggregation/@xmi.value"/>

	<xsl:choose>
		<xsl:when test="$class1='none'">2</xsl:when>
		<xsl:otherwise>1</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<!-- retourne le supplier de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationSupplier">
	<xsl:variable name="class1" select="Foundation.Core.AssociationEnd[1]/Foundation.Core.AssociationEnd.aggregation/@xmi.value"/>

	<xsl:choose>
		<xsl:when test="$class1='none'">1</xsl:when>
		<xsl:otherwise>2</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<!-- retourne la navigabilité de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationNavigability">
	
	<xsl:variable name="client"><xsl:apply-templates select="Foundation.Core.Association.connection" mode="GetAssociationClient"/></xsl:variable>
	
	<xsl:variable name="clientNavigability" select="Foundation.Core.AssociationEnd[position()=$client]/Foundation.Core.AssociationEnd.isNavigable/@xmi.value"/>
	
	<xsl:variable name="associationType"><xsl:apply-templates select="." mode="GetAssociationType"/></xsl:variable>
	
	<xsl:choose>
		<xsl:when test="$associationType='association'">false</xsl:when>
		<xsl:otherwise>
			<xsl:choose>
				<xsl:when test="$clientNavigability='true'">false</xsl:when>
				<xsl:otherwise>true</xsl:otherwise>
			</xsl:choose>
		</xsl:otherwise>
	</xsl:choose>

</xsl:template>

<!-- retourne le nom de la classe client/supplier de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationClassName">
	<xsl:param name="role"/>
	
	<xsl:variable name="clientId" select="Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.type/Foundation.Core.Interface/@xmi.idref | Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.type/Foundation.Core.Class/@xmi.idref | Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.type/Foundation.Core.AssociationClass/@xmi.idref"/>

	<xsl:value-of select="key('classId', $clientId)/Foundation.Core.ModelElement.name"/>	
</xsl:template>

<!-- retourne le role du client/supplier de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationRoleName">
	<xsl:param name="role"/>
	
	<xsl:value-of select="Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.ModelElement.name"/>	
</xsl:template>

<!-- retourne la multiplicité du client/supplier de l'association -->
<xsl:template match="Foundation.Core.Association.connection" mode="GetAssociationMultiplicity">
	<xsl:param name="role"/>
	
	<xsl:variable name="xmiMultiplicity" select="Foundation.Core.AssociationEnd[position()=$role]/Foundation.Core.AssociationEnd.multiplicity"/>

	<xsl:choose>
		<xsl:when test="$xmiMultiplicity='1..1'">1</xsl:when>
		<xsl:otherwise><xsl:value-of select="$xmiMultiplicity"/></xsl:otherwise>
	</xsl:choose>
</xsl:template>

</xsl:stylesheet>
